#include <stdio.h>

int majorityElement(int* nums, int numsSize)
{
    int count = 1;
    int num = nums[0];
    for(int i = 1;i < numsSize;i++)
    {
        if(num == nums[i])
        {
            count++;
        }
        else
        {
            if(count == 0)
            {
                num == nums[i];
                count++;
            }
            else
            {
                count--;
            }
        }
    }
    return num;
}

int main()
{
    int nums[] = {2,2,2,1,1,3,2};
    int numsSize = sizeof(nums)/sizeof(nums[0]);
    printf("%d\n",majorityElement(nums, numsSize));
    return 0;
}